;+
; Converts a uniform parameter to physical for a given prior type and 
; specification
;-
function hod_priorpar,uval,ptype,pspec,reverse=reverse
  if not keyword_set(reverse) then begin
     case ptype of
        0: val=pspec[0]                               ; delta fn
        1: val=uval*(pspec[1]-pspec[0])+pspec[0]      ; constant
        2: val=10^( uval*(pspec[1]-pspec[0])+pspec[0] ) ; log constant
        3: begin                                        ;  Gaussian
           uval=uval>1e-4<1-1e-4
           sig=dierfc(2-2*(uval))*sqrt(2)
           val=pspec[0]+sig*pspec[1]
        end
     endcase
  endif else begin
     ; converting parameters-> upar values
     val=uval
     case ptype of
        0: uval=0.5                                      ; delta fn
        1: uval=(val-pspec[0])/(pspec[1]-pspec[0])       ; constant
        2: uval=(alog10(val)-pspec[0])/(pspec[1]-pspec[0]) ; log constant
        3: begin                                        ;  Gaussian
           ;;*** TO DO 
        end
     endcase
     val=uval
  endelse
  
  return,val
end
